
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @ClassName A10
 * @Description
 * @Author Jingxiao.Ye
 * @Date 2021/11/28 下午11:50
 * @Version V1.0
 * @Since JDK 11
 */
public class A10 {

    public static void main(String[] args) throws BrokenBarrierException, InterruptedException {
        BlockingQueue<Integer> queue = new LinkedBlockingQueue<>(1);
        Thread thread = new Thread(() -> {
            try {
                Integer call = new Task().call();
                queue.offer(call);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        thread.start();
        Integer poll = queue.poll(1, TimeUnit.SECONDS);
        System.out.println(poll);
    }
}
